/*
* @Author: steven.wang
* @Date:   2019-03-23 03:44:41
* @Last Modified by:   steven.wang
* @Last Modified time: 2019-05-15 10:41:02
*/
const JobModel = require('../../models/crawler/job');
/**
 * 查询职位
 * @author steven.wang
 * @DateTime 2019-03-23T03:45:07+0800
 */
exports.list = async (req, res) => {
	req.query.sorts = req.query.sorts || 'createAt desc'
	let jobs = await JobModel.list(req.query);
	let count = await JobModel.count(req.query);
	res.json({
		success: true,
		msg: '',
		data: {
			page: req.query.page || 1,
			pageSize: req.query.pageSize || 10,
			total: count[0]['count(*)'],
			list: jobs
		}
	})
}
/**
 * 添加职位
 * @author steven.wang
 * @DateTime 2019-03-23T03:45:07+0800
 */
exports.addJobs = async (req, res) => {
	let result = await JobModel.add(req.body);
	console.log(result)
	res.json({
		success: true,
		msg: ''
	})
}
/**
 * 更新职位
 * @author steven.wang
 * @DateTime 2019-03-23T03:45:07+0800
 */
exports.updateJobs = async (req, res) => {
	let result = await JobModel.update(req.body);
	console.log(result)
	res.json({
		success: true,
		msg: ''
	})
}
/**
 * 删除职位
 * @author steven.wang
 * @DateTime 2019-03-23T03:45:07+0800
 */
exports.deleteJobs = async (req, res) => {
	let result = await JobModel.delete(req.body);
	console.log(result);
	res.json({
		success: true,
		msg: ''
	})
}